﻿using OccurrencesCore.Model;
using OccurrencesCore.Service;
using OccurrencesWeb.Page;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OccurrencesWeb.Pages.Occurrence
{
    public partial class StartCreation : ExtendedPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
                return;

            rptType.DataSource = new OccurrenceTypeService().FindAll();
            rptType.DataBind();
        }

        protected void rptType_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                OccurrenceType type = e.Item.DataItem as OccurrenceType;
                HyperLink hlkTypeLink = e.Item.FindControl("hlkTypeLink") as HyperLink;

                hlkTypeLink.Text = type.Name;
                hlkTypeLink.NavigateUrl = string.Format("/Occurrence/Add/{0}", type.Id);
            }

        }
    }
}